/**
 * @fileOverview JavaScript should not be loaded on an HTML page.  Doing that
 * means you have multiple places to maintain your scripts.  That leads to bad
 * programming things.  We use this loader.js file to call new different
 * JavaScript functions that are needed to run on each page.  
 * @author Joe Cianflone
 * @version	3.0
 * @copyright CC, Creative Commons Attribution-ShareAlike 3.0 Unported -- http://creativecommons.org/licenses/by-sa/3.0/
 */

/**
 * This allows us to load in new JavaScript files.
 */
LoadScripts.loadByFileName({
	'library/common':'all'
});

/**
 *  This is the same as the body=onload, only better.  We have one place to load all our stuff
 *  and we can load multiple functions correctly. 
 */
Event.observe (window, 'load', function () {
	var currentPage = new Page();
	currentPage.copyright('All Rights Reserved', 'siteInfo');
	
	
	/**
	 * DELETE THIS LINE BEFORE YOU TAKE THIS INTO PRODUCTION
	 */
	_dashboardInit(currentPage);
	
}, false);

/**
 * @private
 * DELETE THIS FUNCTION AND THE CALL ABOVE WHEN PUSHING TO PRODUCTION, THIS
 * IS ONLY NEEDED FOR THE DASHBOARD TO WORK AND THAT SHOULD NOT GO INTO
 * PRODUCTION.  
 */
function _dashboardInit(currPage) {
	var links = $$('.navLink');
	for (var i=0, len=links.length; i < len; ++i) {
		Event.observe (links[i], 'click', function(e) {
			var ele = Event.element(e);
			if (!ele.hasClassName('selected')) {
				var selected = $$('.selected')[0];
				selected.removeClassName('selected');
				var show_content = ele.id + '_content';
				var hide_content = selected.id + '_content';
				$(show_content).setStyle({
					display: 'block'
				});
				$(hide_content).setStyle({
					display: 'none'
				});
				ele.addClassName('selected');
			}//if...		
		}.bindAsEventListener(), false);	
	}//for...
}//dashboardInit()...
